/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.pv.hibernatepokus.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;

/**
 *
 * @author Premek
 */
@Entity
public class Item implements Serializable{
    
    @EmbeddedId
    private ItemPk id;

    @ManyToOne
    @JoinColumn(name="productid")
    private Product product;
        
    private int quantity;
    
    private BigDecimal cost;

    public Item() {
    }

    public Item(Product product, int quantity, BigDecimal cost) {
        this.id = new ItemPk();
        this.product = product;
        this.quantity = quantity;
        this.cost = cost;
    }
    
    public ItemPk getId() {
        return id;
    }

    public void setId(ItemPk id) {
        this.id = id;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public BigDecimal getCost() {
        return cost;
    }

    public void setCost(BigDecimal cost) {
        this.cost = cost;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    @Override
    public String toString() {
        return "Item{" + "id=" + id + ", product=" + product + ", quantity=" + quantity + ", cost=" + cost + '}';
    }
    
}
